import dynamic from 'dva/dynamic'

// 包装动态加载
const dynamicWarpper = (app, models, component) => {
  return dynamic({
      app,
      models: () => models.map(m => import(`../models/${m}.js`)),
      component,
  })
}

// nva data
export const getNavData = app => [
  {
      component: dynamicWarpper(app, ['user', 'login'], () => import('../layouts/BasicLayout')),
      layout: 'BasicLayout',
      name: '首页',
      path: '/',
      children: [
        {
            name: '系统管理',
            icon: 'table',
            path: 'userMgr',
            children: [
                {
                    name: '用户管理',
                    path: 'user',
                    component: dynamicWarpper(app, ['user'], () => import('../routes/usemgr/user')),
                },
            ],
        },
      ],
  },
]
